package com.wwl.gui.bms;

import javafx.application.Application;
import javafx.geometry.HPos;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.scene.Scene;
import javafx.scene.control.*;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.layout.*;
import javafx.stage.Stage;

public class loginForm extends Application {

    public static void main(String[] args) {
        launch(args);
    }

    @Override
    public void start(Stage primaryStage) {
        BorderPane pane = new BorderPane();
        //top
        ImageView imageView = new ImageView(new Image("images/bg2.gif"));
        pane.setTop(imageView);
        //center
        GridPane gp = new GridPane();
        gp.setAlignment(Pos.TOP_CENTER);
        gp.setVgap(8);

        gp.setPadding(new Insets(30,0,10,0));
        TextField tfLoginName = new TextField();
        tfLoginName.setPromptText("登录账号……");
        tfLoginName.setPadding(new Insets(10));
        tfLoginName.setPrefWidth(225);
        tfLoginName.setPrefHeight(30);

        PasswordField pfPassword = new PasswordField();
        pfPassword.setPromptText("登录密码……");
        pfPassword.setPadding(new Insets(10));
        pfPassword.setPrefWidth(225);
        pfPassword.setPrefHeight(30);

        Button btnLogin = new Button("登  录" );
        btnLogin.setPrefHeight(30);
        btnLogin.setPrefWidth(225);

        gp.add(tfLoginName,0,0);
        gp.add(pfPassword,0,1);
        gp.add(btnLogin,0,2);

        pane.setCenter(gp);

        //bottom
        GridPane gp2 = new GridPane();
        gp2.setPadding(new Insets(0,0,20,20));
        gp2.setStyle("-fx-border-color: red;");
        Hyperlink hlRegister = new Hyperlink("注册用户");
        hlRegister.setStyle("-fx-border-color: blue;");
        Hyperlink hlForgotPassword = new Hyperlink("忘记密码");
        hlForgotPassword.setStyle("-fx-border-color: green");

        gp2.add(hlRegister,0,0);
        gp2.add(hlForgotPassword,1,0);
        GridPane.setHalignment(hlRegister, HPos.LEFT);
        GridPane.setHalignment(hlForgotPassword, HPos.RIGHT);
        hlRegister.setUnderline(false);
        hlForgotPassword.setUnderline(false);

        pane.setBottom(gp2);

        Scene scene = new Scene(pane,428,328);
        primaryStage.setResizable(false);
        primaryStage.setTitle("图书管理系统-登录");
        primaryStage.setScene(scene);
        primaryStage.show();
    }
}
